<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lb'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label"><fmt:message key='ymmc'/></label>
                    <div class="layui-input-inline">
                        <input type="text" id="searchName" placeholder="页面名称" value="<c:if test='${params.name !=null}'>${params.name}</c:if>" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                </div>
            </div>
        </div>

    </div>
    <div class="layui-card">
        <div class="layui-field-box layui-form">
            <table id="allotTable"  lay-filter="allotTableFilter" lay-size="sm" ></table>
        </div>
    </div>

</div>
<script type="text/html" id="feijin-operation">
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="allot"><fmt:message key='zd1'/></a>
</script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var layer = layui.layer;
    });

    function search() {

        layui.use('table', function () {
            var table = layui.table;

            table.render({
                elem: '#allotTable'
                , height: 315
                , url: '${web_domain}/securitys/nav/paths'
                , page: true
                , where: {
                    keyword: $("#searchName").val()
                }
                , cols: [[
                     {field: 'name', title: '<fmt:message key='ymmc'/>', width: 180}
                    , {field: 'href', title: '<fmt:message key='ymdz'/>', width: 180}
                    , {field: 'id', title: '<fmt:message key='cz'/>', toolbar: '#feijin-operation', width: 100}
                ]]
            });


            table.on('tool(allotTableFilter)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-eventOfMerchant 对应的值（也可以是表头的 eventOfMerchant 参数对应的值）
                var tr = obj.tr; //获得当前行 tr 的DOM对象

                if (layEvent === 'allot') {
                    if ($('#content', window.parent.document).html().trim() != "") {
                        alert("<fmt:message key='dqyzdlymqxscyyzd'/>");
                        return;
                    }
                    var index = $(".teacher").length;
                    $('#title', window.parent.document).val(data.name);
                    $('#nav', window.parent.document).append("<input type='hidden' name='page.id' value='" + data.id + "' class='teacher' /> ");
                    $('#content', window.parent.document).html($('#content', window.parent.document).html() + "<tr id='tr" + index + "'><td>" + data.name + "</td><td>" + data.href + "</td><td><a href='javascript:void(0);' class='feijin-remove' data-id='" + index + "' ><fmt:message key='sc'/></a></td>");
                    parent.showAuthority(data.id);
                    parent.closeRoute();
                }
            });

        });

    }

    $(function () {
        search();
    });

</script>
</body>
</fmt:bundle>
</html>